#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
ll n, x;
void solve()
{
	cin >> n;
	vector<int> odd, even;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if (x & 1) even.push_back(x);
		else odd.push_back(x);
	}

	for (int i = 0;i <((int)even.size()) - 1; i++)
	{
		if (even[i] > even[i + 1])
		{
			cout << "NO" << '\n'; return;
		}
	}
	for (int i = 0; i < ((int)odd.size()) - 1; i++)
	{
		if (odd[i] > odd[i + 1])
		{
			cout << "NO" << '\n'; return;
		}
	}
	cout << "YES" << '\n';


}

int main()
{
	close();
	int T; cin >> T;
	while (T--) solve();
	return 0;
}
//是任意i
// 3 2 6 4 --> 2 3 6 4-->2 6 3 4